package cz.muni.fi.pa165.web.validation;

import cz.muni.fi.pa165.api.ForestService;
import cz.muni.fi.pa165.api.dto.ForestDTO;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.validation.Errors;
import org.springframework.validation.ValidationUtils;
import org.springframework.validation.Validator;

/**
 * Validation class for editing ForestDTO 
 * @author Matej Cimbora
 */

@Service
public class ForestDTOEditValidator implements Validator {

    @Autowired
    ForestService forestService;
    
    @Override
    public boolean supports(Class<?> type) {
        return ForestDTO.class.equals(type);
    }

    @Override
    public void validate(Object o, Errors errors) {
        ForestDTO forest = (ForestDTO) o;
        ValidationUtils.rejectIfEmptyOrWhitespace(errors, "name", "forest.name.empty");

    }
}
